<?php
class Article
{
	public static function get($id)
	{
		return Db::get(__CLASS__)->select()->where(array('aid'=>$id))->getOne();
	}
	public static function existing($id)
	{
		return Db::get(__CLASS__)->count()->where(array('aid'=>$id))->getCol();
	}

	public static function getList($where, $s=0, $l=0)
	{
		return Db::get(__CLASS__)->select()->where($where)->order('aid DESC')->limit($s, $l)->getAll();
	}
	public static function count($where)
	{
		return Db::get(__CLASS__)->count()->where($where)->getCol();
	}

	public static function add($data)
	{
		return Db::get(__CLASS__)->insert($data)->exec() ? Db::get(__CLASS__)->insertId() : false;
	}
	public static function update($id, $data)
	{
		return Db::get(__CLASS__)->update($data)->where(array('aid'=>$id))->exec();
	}
	public static function delete($id)
	{
		return Db::get(__CLASS__)->delete()->where(array('aid'=>$id))->exec();
	}

}
?>